#include <Windows.h>

#include "CTradeContainer.h"
#include "CSynthResultPacket.h"

CSynthResultPacket::CSynthResultPacket(unsigned char synthResult) {
	this->type = 0x6F;
	this->size = 0x12;
	memset(data, 0, sizeof(data));

	data[0x04-0x04] = synthResult;
}

CSynthResultPacket::CSynthResultPacket(unsigned short itemID, unsigned char quantity, unsigned char synthResult) {
	this->type = 0x6F;
	this->size = 0x12;
	memset(data, 0, sizeof(data));

	data[0x04-0x04] = synthResult;

	data[0x06-0x04] = quantity;
	memcpy(data+0x08-0x04, &itemID, 2);
}

CSynthResultPacket::CSynthResultPacket(CTradeContainer * synthContainer, unsigned char synthResult) {
	this->type = 0x6F;
	this->size = 0x12;
	memset(data, 0, sizeof(data));

	data[0x04-0x04] = synthResult;

	unsigned char count = 0;
	for(unsigned char slotID = 1; slotID <= 8; slotID++) {
		unsigned long quantity = 0;
		quantity = synthContainer->getQuantity(slotID);
		if(quantity == 0) {
			unsigned short itemID = 0;
			itemID = synthContainer->getItemID(slotID);
			memcpy(data+0x0a+(count * 0x02)-0x04, &itemID, 2);
			count++;
		}
	}
}


CSynthResultPacket::~CSynthResultPacket() {
}